﻿using System.ComponentModel.DataAnnotations;
using easyVal.ServerSide;

namespace easyVal.ValidationAttributes
{
    public class RangeValAttribute : RangeAttribute, IClientValidationMethod
    {
        public RangeValAttribute(int minimum, int maximum)
        :base(minimum,maximum)
        {
        }

        #region IClientValidationMethod Members

        public string ClientMethodName
        {
            get { return "range"; }
        }

        public string ClientParameters
        {
            get { return string.Format("[{0},{1}]", Minimum, Maximum); }
        }

        public override bool IsValid(object value)
        {
            if (ValidationAttributeUtil.IsDefaultValue(value))
                return true;

            return base.IsValid(value);
        }

        #endregion

    }
}